package singleton;

/**
 * 双重校验+volitile+锁
 */
public class Singleton06 {

    private static volatile Singleton06 INSTANCE;

    private Singleton06(){}

    public static Singleton06 getInstance(){
        if (INSTANCE == null){
            synchronized (Singleton06.class) {
                if (INSTANCE == null) {
                    INSTANCE = new Singleton06();
                }
            }
        }
        return INSTANCE;
    }


    public static void main(String[] args) {
        Singleton06 i1 = Singleton06.getInstance();
        Singleton06 i2 = Singleton06.getInstance();
        System.out.println(i1 == i2);
    }
}
